package com.maxd.controller.UserCollectOrBrowse;

import com.maxd.error.Result;
import com.maxd.error.ResultUtil;
import com.maxd.model.UserCollectOrBrowse;
import com.maxd.service.UserCollectOrBrowse.UserCollectOrBrowseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "收藏和足迹", tags = {"收藏和足迹"})
@Slf4j
@RequestMapping(value = "/collectOrBrowse")
public class UserCollectOrBrowseController {

    @Autowired
    private UserCollectOrBrowseService userCollectOrBrowseService;

    @PostMapping("/saveUserCollectOrBrowse")
    @ApiOperation("添加收藏或足迹")
    public Result saveUserCollectOrBrowse(@RequestBody UserCollectOrBrowse userCollectOrBrowse){
        return userCollectOrBrowseService.saveUserCollectOrBrowse(userCollectOrBrowse);
    }

    @GetMapping("/selectUserCollectOrBrowse")
    @ApiOperation("根据商品id查询商品")
    public Result selectUserCollectOrBrowse(String goodsId,Integer classify,Long userId){
        return ResultUtil.success(userCollectOrBrowseService.selectUserCollectOrBrowse(goodsId,classify,userId));
    }


    @PostMapping("/deleteUserCollectOrBrowse")
    @ApiOperation("删除足迹或收藏")
    public Result deleteUserCollectOrBrowse(Long id){
        return ResultUtil.success(userCollectOrBrowseService.deleteUserCollectOrBrowse(id));
    }

    @GetMapping("/selectUserCollectOrBrowseList")
    @ApiOperation("查询足迹或收藏列表")
    public Result selectUserCollectOrBrowseList(Integer page,Integer size,Long userId,Integer classify,Integer goodsType){
        return userCollectOrBrowseService.selectUserCollectOrBrowseList(page, size, userId, classify, goodsType);
    }





}
